package br.com.passeionaweb.android.TabelaFipe;

import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.ListAdapter;
import android.widget.SimpleCursorAdapter;
import br.com.passeionaweb.android.TabelaFipe.db.PricesDatabaseHelper;

public class HistoryActivity extends ListActivity {
	private static final String[] from = new String[] { PricesDatabaseHelper.KEY_MAKE,
			PricesDatabaseHelper.KEY_MODEL, PricesDatabaseHelper.KEY_YEAR,
			PricesDatabaseHelper.KEY_VERSION, PricesDatabaseHelper.KEY_PRICE };
	private static final int[] to = new int[] { R.id.make, R.id.model, R.id.year, R.id.version,
			R.id.price };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.history);
		super.onCreate(savedInstanceState);
	}

	@Override
	protected void onResume() {
		super.onResume();
		Cursor cursor = new PricesDatabaseHelper(this).getAllPrices();
		startManagingCursor(cursor);
		ListAdapter adapter = new SimpleCursorAdapter(this, R.layout.history_row, cursor, from, to);
		setListAdapter(adapter);

	}

}
